package com.kedou.sdk.params;

import android.os.Parcel;
import android.os.Parcelable;

import com.google.gson.annotations.SerializedName;
import com.kedou.sdk.params.bean.WindowMessage;

import java.util.ArrayList;

/**
 * Created by Administrator on 2017/6/8 0008.
 */

public class PushInfoResponseParams extends ResponseParams<PushInfoResponseParams.PushInfoResponseData> {

    public static class PushInfoResponseData implements Parcelable {

        @SerializedName("push_data")
        private ArrayList<WindowMessage> windowMessages;

        public ArrayList<WindowMessage> getWindowMessages() {
            return windowMessages;
        }

        public void setWindowMessages(ArrayList<WindowMessage> windowMessages) {
            this.windowMessages = windowMessages;
        }

        public final String getFirstSaveTime(){
            if(windowMessages != null && !windowMessages.isEmpty()){
                WindowMessage windowMessage = windowMessages.get(0);
                if(windowMessage != null){
                    return windowMessage.getSaveTime();
                }
            }
            return String.valueOf(System.currentTimeMillis() / 1000);
        }

        public final boolean isEmpty(){
            return windowMessages == null || windowMessages.isEmpty();
        }

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeList(this.windowMessages);
        }

        public PushInfoResponseData() {
        }

        protected PushInfoResponseData(Parcel in) {
            this.windowMessages = new ArrayList<WindowMessage>();
            in.readList(this.windowMessages, WindowMessage.class.getClassLoader());
        }

        public static final Creator<PushInfoResponseData> CREATOR = new Creator<PushInfoResponseData>() {
            @Override
            public PushInfoResponseData createFromParcel(Parcel source) {
                return new PushInfoResponseData(source);
            }

            @Override
            public PushInfoResponseData[] newArray(int size) {
                return new PushInfoResponseData[size];
            }
        };
    }

}
